package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.FurtherStudyMapper;
import com.digital.smartgrow.dto.title.FurtherStudy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class FurtherStudyServiceImpl implements FurtherStudyService{

    @Autowired
    FurtherStudyMapper furtherStudyMapper;


    @Override
    @Transactional
    public List<FurtherStudy> findList(FurtherStudy furtherStudy) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", furtherStudy.getIdcard());
        queryWrapper.eq("status", 0);
        return furtherStudyMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void deleteCommend(FurtherStudy furtherStudy) {
        FurtherStudy furtherStudy1 = new FurtherStudy();
        Date date = new Date();
        furtherStudy1.setStatus(1).setId(furtherStudy.getId()).setTime(date);
        furtherStudyMapper.updateById(furtherStudy1);
    }
}
